/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FramePrincipal.java
 *
 * Created on 17/01/2011, 17:45:01
 */
package gui.frames;

import gui.frames.utils.MyDesktopPanel;
import controle.gui.frames.ControleFramePrincipal;
import gui.frames.internos.*;

/**
 * @author Maycon Fernando Silva Brito
 * @email mayconfsbrito@gmail.com
 */
public class FramePrincipal extends javax.swing.JFrame {

    ControleFramePrincipal controle = new ControleFramePrincipal(this);
    

    /**
     * Creates new form FramePrincipal
     */
    public FramePrincipal() {
        controle.inicializaTema();
        initComponents();
        this.setExtendedState(MAXIMIZED_BOTH);
        controle.inicializa();
    }

    /**
     * Executa a interface gráfica do frame principal
     *
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new FramePrincipal().setVisible(true);
            }
        });
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        desktopPanel = new MyDesktopPanel();
        panelLateral = new javax.swing.JPanel();
        labelUsuario = new javax.swing.JLabel();
        buttonLogin = new javax.swing.JButton();
        buttonLogoff = new javax.swing.JButton();
        labelDesconectado = new javax.swing.JLabel();
        labelConectado = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        menuBoletins = new javax.swing.JMenu();
        menuItemBoletinsPesquisa = new javax.swing.JMenuItem();
        menuItemBoletinsTratamento = new javax.swing.JMenuItem();
        menuLaboratorio = new javax.swing.JMenu();
        menuItemLabBoletinsPendentes = new javax.swing.JMenuItem();
        menuLocais = new javax.swing.JMenu();
        menuItemMunicipio = new javax.swing.JMenuItem();
        menuItemLocalidade = new javax.swing.JMenuItem();
        menuItemLograouro = new javax.swing.JMenuItem();
        menuItemQuadra = new javax.swing.JMenuItem();
        menuItemImovel = new javax.swing.JMenuItem();
        menuRelatorio = new javax.swing.JMenu();
        menuItemBoletinsDiarios = new javax.swing.JMenuItem();
        menuItemLogUsuarios = new javax.swing.JMenuItem();
        menuItemResumoSemanal = new javax.swing.JMenuItem();
        menuOpcoes = new javax.swing.JMenu();
        menuItemPreferencias = new javax.swing.JMenuItem();
        menuSincronizacao = new javax.swing.JMenuItem();
        menuUsuarios = new javax.swing.JMenu();
        menuItemUsuariosAlterarSenha = new javax.swing.JMenuItem();
        menuItemUsuariosGerenciar = new javax.swing.JMenuItem();
        menuAjuda = new javax.swing.JMenu();
        menuItemSobre = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Sistema de Monitoramento da Dengue 1.0");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setMinimumSize(new java.awt.Dimension(1024, 760));

        desktopPanel.setBackground(new java.awt.Color(255, 255, 255));
        desktopPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        desktopPanel.setToolTipText("");
        desktopPanel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        panelLateral.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        labelUsuario.setFont(new java.awt.Font("DejaVu Sans", 0, 10)); // NOI18N
        labelUsuario.setText("Usuário Desconectado");

        buttonLogin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/Login.png"))); // NOI18N
        buttonLogin.setText("Login");
        buttonLogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonLoginActionPerformed(evt);
            }
        });

        buttonLogoff.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/Logoff.png"))); // NOI18N
        buttonLogoff.setText("Logoff");
        buttonLogoff.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonLogoffActionPerformed(evt);
            }
        });

        labelDesconectado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/Desconectado.png"))); // NOI18N

        labelConectado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/Conectado.png"))); // NOI18N

        javax.swing.GroupLayout panelLateralLayout = new javax.swing.GroupLayout(panelLateral);
        panelLateral.setLayout(panelLateralLayout);
        panelLateralLayout.setHorizontalGroup(
            panelLateralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelLateralLayout.createSequentialGroup()
                .addGroup(panelLateralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(panelLateralLayout.createSequentialGroup()
                        .addComponent(labelDesconectado, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(labelConectado, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelLateralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(buttonLogoff, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(buttonLogin, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        panelLateralLayout.setVerticalGroup(
            panelLateralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelLateralLayout.createSequentialGroup()
                .addGroup(panelLateralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(labelDesconectado, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
                    .addComponent(labelConectado, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(labelUsuario)
                .addGap(18, 18, 18)
                .addComponent(buttonLogin)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonLogoff)
                .addContainerGap(404, Short.MAX_VALUE))
        );

        menuBoletins.setText("Boletins");

        menuItemBoletinsPesquisa.setText("Boletins de Pesquisa");
        menuItemBoletinsPesquisa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemBoletinsPesquisaActionPerformed(evt);
            }
        });
        menuBoletins.add(menuItemBoletinsPesquisa);

        menuItemBoletinsTratamento.setText("Boletins de Tratamento");
        menuItemBoletinsTratamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemBoletinsTratamentoActionPerformed(evt);
            }
        });
        menuBoletins.add(menuItemBoletinsTratamento);

        menuBar.add(menuBoletins);

        menuLaboratorio.setText("Laboratório");

        menuItemLabBoletinsPendentes.setText("Boletins Pendentes");
        menuItemLabBoletinsPendentes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemLabBoletinsPendentesActionPerformed(evt);
            }
        });
        menuLaboratorio.add(menuItemLabBoletinsPendentes);

        menuBar.add(menuLaboratorio);

        menuLocais.setText("Locais");

        menuItemMunicipio.setText("Municípios");
        menuItemMunicipio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemMunicipioActionPerformed(evt);
            }
        });
        menuLocais.add(menuItemMunicipio);

        menuItemLocalidade.setText("Localidades");
        menuItemLocalidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemLocalidadeActionPerformed(evt);
            }
        });
        menuLocais.add(menuItemLocalidade);

        menuItemLograouro.setText("Logradouros");
        menuItemLograouro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemLograouroActionPerformed(evt);
            }
        });
        menuLocais.add(menuItemLograouro);

        menuItemQuadra.setText("Quadras");
        menuItemQuadra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemQuadraActionPerformed(evt);
            }
        });
        menuLocais.add(menuItemQuadra);

        menuItemImovel.setText("Imóveis");
        menuItemImovel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemImovelActionPerformed(evt);
            }
        });
        menuLocais.add(menuItemImovel);

        menuBar.add(menuLocais);

        menuRelatorio.setText("Relatórios");

        menuItemBoletinsDiarios.setText("Boletins Diários");
        menuItemBoletinsDiarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemBoletinsDiariosActionPerformed(evt);
            }
        });
        menuRelatorio.add(menuItemBoletinsDiarios);

        menuItemLogUsuarios.setText("Log de Usuários");
        menuItemLogUsuarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemLogUsuariosActionPerformed(evt);
            }
        });
        menuRelatorio.add(menuItemLogUsuarios);

        menuItemResumoSemanal.setText("Resumo Semanal de Boletins");
        menuItemResumoSemanal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemResumoSemanalActionPerformed(evt);
            }
        });
        menuRelatorio.add(menuItemResumoSemanal);

        menuBar.add(menuRelatorio);

        menuOpcoes.setText("Opções");
        menuOpcoes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuOpcoesActionPerformed(evt);
            }
        });

        menuItemPreferencias.setText("Preferências");
        menuItemPreferencias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemPreferenciasActionPerformed(evt);
            }
        });
        menuOpcoes.add(menuItemPreferencias);

        menuSincronizacao.setText("Sincronização");
        menuSincronizacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuSincronizacaoActionPerformed(evt);
            }
        });
        menuOpcoes.add(menuSincronizacao);

        menuUsuarios.setText("Usuários");

        menuItemUsuariosAlterarSenha.setText("Alterar minha senha");
        menuItemUsuariosAlterarSenha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemUsuariosAlterarSenhaActionPerformed(evt);
            }
        });
        menuUsuarios.add(menuItemUsuariosAlterarSenha);

        menuItemUsuariosGerenciar.setText("Gerenciar usuários");
        menuItemUsuariosGerenciar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemUsuariosGerenciarActionPerformed(evt);
            }
        });
        menuUsuarios.add(menuItemUsuariosGerenciar);

        menuOpcoes.add(menuUsuarios);

        menuBar.add(menuOpcoes);

        menuAjuda.setText("Ajuda");

        menuItemSobre.setText("Informações sobre...");
        menuItemSobre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemSobreActionPerformed(evt);
            }
        });
        menuAjuda.add(menuItemSobre);

        menuBar.add(menuAjuda);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(desktopPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 782, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelLateral, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPanel)
            .addComponent(panelLateral, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void menuOpcoesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuOpcoesActionPerformed
    }//GEN-LAST:event_menuOpcoesActionPerformed

    private void menuItemPreferenciasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemPreferenciasActionPerformed

        //Abre no desktopPane o frame interno para gerenciamento de Agentes/Usuários
        IFPreferencias iFrame = new IFPreferencias();
        FramePrincipal.desktopPanel.add(iFrame);

        //Focaliza o novo JInternalFrame
        desktopPanel.getDesktopManager().activateFrame(iFrame);

    }//GEN-LAST:event_menuItemPreferenciasActionPerformed

private void buttonLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonLoginActionPerformed
    ControleFramePrincipal.abreIFLogin();
}//GEN-LAST:event_buttonLoginActionPerformed

private void buttonLogoffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonLogoffActionPerformed
    ControleFramePrincipal.logoff();
}//GEN-LAST:event_buttonLogoffActionPerformed

    private void menuItemUsuariosGerenciarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemUsuariosGerenciarActionPerformed
        controle.menuItemUsuariosGerenciarActionPerformed();
    }//GEN-LAST:event_menuItemUsuariosGerenciarActionPerformed

    private void menuItemUsuariosAlterarSenhaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemUsuariosAlterarSenhaActionPerformed
        controle.menuItemUsuariosAlterarSenhaActionPerformed();
    }//GEN-LAST:event_menuItemUsuariosAlterarSenhaActionPerformed

    private void menuItemMunicipioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemMunicipioActionPerformed
        controle.menuItemMunicipioActionPerformed();
    }//GEN-LAST:event_menuItemMunicipioActionPerformed

    private void menuItemLocalidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemLocalidadeActionPerformed
        controle.menuItemLocalidadeActionPerformed();
    }//GEN-LAST:event_menuItemLocalidadeActionPerformed

    private void menuItemQuadraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemQuadraActionPerformed
        controle.menuItemQuadraActionPerformed();
    }//GEN-LAST:event_menuItemQuadraActionPerformed

    private void menuItemLograouroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemLograouroActionPerformed
        controle.menuItemLograouroActionPerformed();
    }//GEN-LAST:event_menuItemLograouroActionPerformed

    private void menuItemImovelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemImovelActionPerformed
        controle.menuItemImovelActionPerformed();
    }//GEN-LAST:event_menuItemImovelActionPerformed

    private void menuItemBoletinsTratamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemBoletinsTratamentoActionPerformed
        controle.menuItemBoletinsTratamentoActionPerformed();
    }//GEN-LAST:event_menuItemBoletinsTratamentoActionPerformed

    private void menuItemBoletinsPesquisaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemBoletinsPesquisaActionPerformed
        controle.menuItemBoletinsPesquisaActionPerformed();
    }//GEN-LAST:event_menuItemBoletinsPesquisaActionPerformed

    private void menuItemLabBoletinsPendentesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemLabBoletinsPendentesActionPerformed
        controle.menuItemLabBoletinsPendentesActionPerformed();
    }//GEN-LAST:event_menuItemLabBoletinsPendentesActionPerformed

    private void menuSincronizacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuSincronizacaoActionPerformed
        controle.menuSincronizacaoActionPerformed();
    }//GEN-LAST:event_menuSincronizacaoActionPerformed

    private void menuItemLogUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemLogUsuariosActionPerformed
        controle.menuItemLogUsuariosActionPerformed();
    }//GEN-LAST:event_menuItemLogUsuariosActionPerformed

    private void menuItemBoletinsDiariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemBoletinsDiariosActionPerformed
        controle.menuItemBoletinsDiariosActionPerformed();
    }//GEN-LAST:event_menuItemBoletinsDiariosActionPerformed

    private void menuItemResumoSemanalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemResumoSemanalActionPerformed
        controle.menuItemResumoSemanalActionPerformed();
    }//GEN-LAST:event_menuItemResumoSemanalActionPerformed

    private void menuItemSobreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemSobreActionPerformed
        controle.menuItemSobreActionPerformed();
    }//GEN-LAST:event_menuItemSobreActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    public static javax.swing.JButton buttonLogin;
    public static javax.swing.JButton buttonLogoff;
    public static javax.swing.JDesktopPane desktopPanel;
    public javax.swing.JLabel labelConectado;
    public javax.swing.JLabel labelDesconectado;
    public javax.swing.JLabel labelUsuario;
    public javax.swing.JMenu menuAjuda;
    private javax.swing.JMenuBar menuBar;
    public javax.swing.JMenu menuBoletins;
    public javax.swing.JMenuItem menuItemBoletinsDiarios;
    public javax.swing.JMenuItem menuItemBoletinsPesquisa;
    public javax.swing.JMenuItem menuItemBoletinsTratamento;
    public javax.swing.JMenuItem menuItemImovel;
    public javax.swing.JMenuItem menuItemLabBoletinsPendentes;
    public javax.swing.JMenuItem menuItemLocalidade;
    public javax.swing.JMenuItem menuItemLogUsuarios;
    public javax.swing.JMenuItem menuItemLograouro;
    public javax.swing.JMenuItem menuItemMunicipio;
    public javax.swing.JMenuItem menuItemPreferencias;
    public javax.swing.JMenuItem menuItemQuadra;
    public javax.swing.JMenuItem menuItemResumoSemanal;
    private javax.swing.JMenuItem menuItemSobre;
    public static javax.swing.JMenuItem menuItemUsuariosAlterarSenha;
    public javax.swing.JMenuItem menuItemUsuariosGerenciar;
    public javax.swing.JMenu menuLaboratorio;
    public javax.swing.JMenu menuLocais;
    public javax.swing.JMenu menuOpcoes;
    public javax.swing.JMenu menuRelatorio;
    private javax.swing.JMenuItem menuSincronizacao;
    public static javax.swing.JMenu menuUsuarios;
    public javax.swing.JPanel panelLateral;
    // End of variables declaration//GEN-END:variables

}
